import math
m = 5
half = 1
k = 1
size = int(math.pow(2, m))
matchList = [[1 for i in range(0, size)] for j in range(0, size)]

while k<=m:
    for i in range(0, half):
        for j in range(0, half):
            matchList[i][j + half] = matchList[i][j] + half

    for i in range(0, half):
        for j in range(0, half):
            matchList[i + half][j] = matchList[i][j + half]
            matchList[i + half][j + half] = matchList[i][j]

    half *= 2
    k += 1

for row in matchList:
    print(row)


